from jinja2 import Environment, FileSystemLoader

from config import BaseConfig

env = Environment(loader=FileSystemLoader(
    searchpath=BaseConfig.WS_AGENT_JSX_TEMPLATE_PATH),
    keep_trailing_newline=True)

data = {'sitemap': [{'href': 'http://www.baidu.com',
                     'children': [{'href': 'http://www.baidu2.com'},
                                  {'href': 'http://www.baidu2.com',
                                   'children': [{'href': 'http://www.baidu2.com'},
                                        {'href': 'http://www.baidu2.com'}]}]}]}
output = env.get_template("recursive.jinja2").render(data)

print output
